package com.repeat.member.mq.consump;

import com.repeat.member.config.TopicConfig;
import com.shop.common.constant.RabbitFinalConstant;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class TopicConsump {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = TopicConfig.TOPIC_QUEUE1),
            // 明确指定要使用的 Exchange Bean 的名称
            exchange = @Exchange(name = TopicConfig.TOPIC_EXCHANGE, type = "topic"),
            key = "*.weather.*"
    ))
    public void receiveQueue1(String message) {
        System.out.println("队列1收到weather消息: " + message);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = TopicConfig.TOPIC_QUEUE2),
            // 明确指定要使用的 Exchange Bean 的名称
            exchange = @Exchange(name = TopicConfig.TOPIC_EXCHANGE, type = "topic"),
            key = "lazy.#"
    ))
    public void receiveQueue2(String message) {
        System.out.println("队列2收到lazy消息: " + message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = TopicConfig.TOPIC_QUEUE3),
            // 明确指定要使用的 Exchange Bean 的名称
            exchange = @Exchange(name = TopicConfig.TOPIC_EXCHANGE, type = "topic"),
            key = "*.*.new"
    ))
    public void receiveQueue3(String message) {
        System.out.println("队列3收到new消息: " + message);
    }
}
